Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE!] [New feature]: Incorporate Delivery/Livraison bags #549

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

ThomasDelsart
Copy link
Contributor

@ThomasDelsart ThomasDelsart commented Nov 4, 2024

Initial Implementation: Delivery Bag Notifications
This PR introduces a feature for receiving notifications related to new Delivery Bags. This is an early implementation, shared to prevent redundant work and foster collaboration. It’s not intended for immediate merging. This has been tested a few scanning runs. It works smoothly but requires more testing before merging. Further discussion is also needed to refine the scope of the feature for this project (CC @Der-Henning )

This PR is a first attempt to solve the following issues:
Resolves #533
Resolves #529

Key Changes

  • API Integration: Added API calls to fetch information about delivery bags. Needed endpoint has been found from the relevant Issue discussion.
  • Data Processing: Introduced logic to read, parse, and convert delivery bag data into Item objects.
  • Continuous Monitoring: Implemented a monitoring mechanism via self.delivery_state to track the status of delivery items and send notifications if new bags appear.
  • Add a configuration option to enable/disable this new feature

Workflow

  • Initial Scan: On startup, the scanner checks all available delivery bags and triggers a notification for each one.
  • Iterative Checks: During each scan cycle, the system:
    • Removes bags that are out of stock from self.delivery_state.
    • Adds the new bags to self.delivery_state and sends notifications for these new items.

Potential Improvements

  • Enhance notifications with additional details about each delivery bag.
  • Tag notifications with a "Delivery" label for easier identification.
  • Send only one notification for all new delivery bags (especially useful for the startup of the scanner)
  • For the API call, some options in the json data are disabled, because they were not tested yet.

@ThomasDelsart ThomasDelsart changed the title [DO NOT MERGE!] New feature: Incorporate Delivery/Livraison bags [DO NOT MERGE!] [New feature]: Incorporate Delivery/Livraison bags Nov 4, 2024
@@ -104,6 +106,15 @@ def _job(self) -> None:
except TgtgAPIError as err:
log.error(err)
items += self._get_favorites()

# if state is empty (first scanning iteration), initialize it with the current favorite items
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SEE PR #548

@@ -221,3 +224,16 @@ def __getattribute__(self, __name: str) -> Any:
if _type == "duration":
return self._get_duration(_mode)
raise

@classmethod
def delivery_item_conversion(cls):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed because delivery bags have not the same attributes in the API call than Items

@@ -86,6 +86,9 @@ def __init__(self, data: dict, location: Union[Location, None] = None, locale: s
store: dict = data.get("store", {})
self.store_name: str = store.get("store_name", "-")

self.manufacturer_properties: dict = data.get("manufacturer_properties", {})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New attributes for delivery items

@@ -135,6 +148,41 @@ def _get_favorites(self) -> list[Item]:
return []
return [Item(item, self.location, self.config.locale) for item in items]

def convert_raw_delivery_item(self, raw_delivery_item: dict, mapping: dict) -> Item:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conversion of delivery data, not in the same format as item data. Adding some logic to have correct format to build the Item object

"element_types_accepted": [
"ITEM", # All items/products in delivery
"HIGHLIGHTED_ITEM", # Item with a special highlight on the top of the delivery pannel
# "DUO_ITEMS",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not tested yet so still there but commented

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Monitor "Livraison" side of the application Add notifications fon new manufactureitem endpoint.
1 participant